package org.jeecg.modules.friends.service.impl;

import java.util.Date;

import org.apache.commons.collections4.CollectionUtils;
import org.jeecg.modules.friends.condition.UserReportCondition;
import org.jeecg.modules.friends.dao.UserReportDAO;
import org.jeecg.modules.friends.enums.UserReportStatusEnum;
import org.jeecg.modules.friends.model.UserReportDO;
import org.jeecg.modules.friends.user.param.ReportUserParam;
import org.jeecg.modules.friends.utils.JacksonUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UserReportServiceImpl implements org.jeecg.modules.friends.service.UserReportService {
    @Autowired
    private UserReportDAO userReportDAO;

    @Override
    public void report(ReportUserParam reportUserParam, Long fromUserId) {
        UserReportDO userReportDO = new UserReportDO();
        userReportDO.setFromUserId(fromUserId);
        userReportDO.setToUserId(reportUserParam.getReportUserId());
        userReportDO.setRemark(reportUserParam.getRemark());
        if (CollectionUtils.isNotEmpty(reportUserParam.getPicUrls())) {
            userReportDO.setPics(JacksonUtil.writeValueAsString(reportUserParam.getPicUrls()));
        }
        userReportDO.setStatus(UserReportStatusEnum.INIT.getCode());
        userReportDO.setAddTime(new Date());
        userReportDO.setUpdateTime(new Date());
        userReportDAO.insert(userReportDO);
    }

    @Override
    public void deleteByUserId(Long userId) {
        userReportDAO.deleteByCondition(userId);
    }

    @Override
    public void handleReport(Long id) {

    }
}
